from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time


def she():
    dr = webdriver.Chrome(service=Service('chromedriver.exe'))
    dr.maximize_window()
    dr.get('https://sahitest.com/demo/confirmTest.htm')
    return dr


def run(dr):
    dr.find_element(By.XPATH, '/html/body/form/input[1]').click()
    time.sleep(2)
    # 点击弹窗确定按钮
    dr.switch_to.alert.accept()
    # time.sleep(2)
    # # 点击弹窗取消按钮
    # dr.switch_to.alert.dismiss()


if __name__ == '__main__':
    dr = she()
    run(dr)
